package com.zivwu.library.dao.local;

import com.google.gson.Gson;
import com.zivwu.library.dao.local.cache.DiskLruCache;
import com.zivwu.library.utils.MD5;

import java.io.IOException;


public class LocalService {


    DiskLruCache cache;

    public <T> T getCache(Class<T> classOfT) throws IOException {
        Gson gson = new Gson();
        DiskLruCache.Snapshot snapshot = cache.get(new MD5().hashKeyForDisk(classOfT.getName()));
        T t1 = gson.fromJson(snapshot.getString(0), classOfT);
        return t1;
    }
}
